<template>
  <AxiomGroup direction="vertical" gap="large">
    <AxiomGroup direction="vertical" gap="small">
      <AxiomText weight="bold" size="large">最终配置确认</AxiomText>
      <AxiomText type="secondary">请在执行前，最后一次检查您的索引配置。</AxiomText>
    </AxiomGroup>

    <AxiomCard>
      <template #header>
        <AxiomText weight="bold" size="medium">待索引的文档</AxiomText>
      </template>
      <AxiomGroup v-if="documents && documents.length > 0" wrap gap="small">
        <AxiomTag v-for="doc in documents" :key="doc.document_id">
          {{ doc.original_file_name || `文档ID: ${doc.document_id}` }}
        </AxiomTag>
      </AxiomGroup>
      <AxiomEmpty v-else description="没有指定要索引的文档。" />
    </AxiomCard>

    <AxiomCard>
      <template #header>
        <AxiomText weight="bold" size="medium">索引策略与流水线</AxiomText>
      </template>
      <AxiomGroup v-if="config && config.pipelines && config.pipelines.length > 0" direction="vertical" gap="normal">
        <AxiomCard v-for="(pipeline, index) in config.pipelines" :key="index" bordered>
            <template #header>
              <AxiomText weight="bold" size="small">流水线 #{{ index + 1 }}</AxiomText>
            </template>
            <AxiomGroup direction="vertical" gap="small">
                <AxiomGroup justify="space-between">
                    <AxiomText weight="bold">分块模式:</AxiomText>
                    <AxiomText>{{ parserTypeLabels[pipeline.parser_type] || pipeline.parser_type }}</AxiomText>
                </AxiomGroup>
                <AxiomGroup justify="space-between">
                    <AxiomText weight="bold">集合后缀:</AxiomText>
                    <AxiomText>{{ pipeline.collection_name_suffix || '无' }}</AxiomText>
                </AxiomGroup>

                <!-- Sentence Splitter -->
                <template v-if="pipeline.parser_type === 'sentence_splitter' && pipeline.sentence_splitter_config">
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">分块大小:</AxiomText><AxiomText>{{ pipeline.sentence_splitter_config.chunk_size }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">重叠大小:</AxiomText><AxiomText>{{ pipeline.sentence_splitter_config.chunk_overlap }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">段落分隔符:</AxiomText><AxiomText>'{{ pipeline.sentence_splitter_config.paragraph_separator }}'</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">二级分块正则:</AxiomText><AxiomText>{{ pipeline.sentence_splitter_config.secondary_chunking_regex }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">上下文关联:</AxiomText><AxiomText>{{ pipeline.sentence_splitter_config.include_prev_next_rel ? '是' : '否' }}</AxiomText></AxiomGroup>
                </template>

                <!-- Token Splitter -->
                <template v-if="pipeline.parser_type === 'token_splitter' && pipeline.token_splitter_config">
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">分块大小:</AxiomText><AxiomText>{{ pipeline.token_splitter_config.chunk_size }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">重叠大小:</AxiomText><AxiomText>{{ pipeline.token_splitter_config.chunk_overlap }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">分隔符:</AxiomText><AxiomText>'{{ pipeline.token_splitter_config.separator }}'</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">上下文关联:</AxiomText><AxiomText>{{ pipeline.token_splitter_config.include_prev_next_rel ? '是' : '否' }}</AxiomText></AxiomGroup>
                </template>

                <!-- Semantic Splitter -->
                <template v-if="pipeline.parser_type === 'semantic_splitter' && pipeline.semantic_splitter_config">
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">缓冲区大小:</AxiomText><AxiomText>{{ pipeline.semantic_splitter_config.buffer_size }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">断点阈值:</AxiomText><AxiomText>{{ pipeline.semantic_splitter_config.breakpoint_percentile_threshold }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">嵌入模型:</AxiomText><AxiomText>{{ pipeline.semantic_splitter_config.embedding_profile_name || 'N/A' }}</AxiomText></AxiomGroup>
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">上下文关联:</AxiomText><AxiomText>{{ pipeline.semantic_splitter_config.include_prev_next_rel ? '是' : '否' }}</AxiomText></AxiomGroup>
                </template>

                <!-- Markdown Splitter -->
                <template v-if="pipeline.parser_type === 'markdown_node' && pipeline.markdown_node_parser_config">
                    <AxiomGroup justify="space-between"><AxiomText weight="bold">上下文关联:</AxiomText><AxiomText>{{ pipeline.markdown_node_parser_config.include_prev_next_rel ? '是' : '否' }}</AxiomText></AxiomGroup>
                </template>
            </AxiomGroup>
        </AxiomCard>
      </AxiomGroup>
      <AxiomEmpty v-else description="未配置索引流水线。" />
    </AxiomCard>
  </AxiomGroup>
</template>

<script setup>
import { 
    AxiomEmpty, 
    AxiomCard, 
    AxiomText, 
    AxiomTag, 
    AxiomGroup
} from 'axiom-view';

const props = defineProps({
  documents: { type: Array, required: true },
  config: { type: Object, required: true },
});

const parserTypeLabels = {
  'sentence_splitter': '普通分块',
  'token_splitter': 'Token分块',
  'semantic_splitter': '语义分块',
  'markdown_node': 'Markdown分块'
};
</script> 